﻿using System;
using System.Collections.Generic;
using System.Diagnostics.Contracts;
using System.Linq;
using System.Text;
using Ruleweaver.Rules.CheckMethods;

namespace Ruleweaver.Annotation
{
	public sealed class CheckEndsWithAttribute : CheckAttribute
	{
		public CheckEndsWithAttribute(string value)
		{
			Contract.Requires(!String.IsNullOrEmpty(value));

			Value = value;
		}

		public CheckEndsWithAttribute(string value, StringComparison comparison) : this(value)
		{
			Comparison = comparison;
		}

		public string Value { get; private set; }

		public StringComparison? Comparison { get; private set; }

		protected override ICheckMethod GetCheckMethod()
		{
			return Comparison == null ? new EndsWithMethod(Value) : new EndsWithMethod(Value, Comparison.Value);
		}
	}
}